package com.cn.wang.demo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class Person implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	
	private int age;
	private String name;
		
	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Person(){
		
	}

	public static void main(String[] args){
		Person one = new Person();
		Person two = new Person();
		Person three = new Person();
		one.setAge(100);
		two.setAge(28);
		three.setAge(30);
		List<Person> list = new ArrayList<Person>();
		list.add(one);
		list.add(two);
		list.add(three);
		Collections.sort(list,new PersonComparators());
		Iterator iterator = list.iterator();
		while(iterator.hasNext()){
			Person person = (Person)iterator.next();
			System.out.println(person.getAge());
		}
	}
}
